﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Company.aspx.cs" Inherits="Catering.Catering_Page.system.Company" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../../Style/center.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/zhezhao.js" type="text/javascript"></script>
    <link href="../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <link href="../../Style/sysData.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        //显示添加
        function Add() {
            $("#btnEdit").hide();
            $("#btnAdd").show();
            divshow("main", "bg");
        }

        //显示修改
        function Edit(cid) {
            $("#HidID").val(cid);

            $.ajax({
                type: "Post",
                url: "Company.aspx/Get",
                data: "{'cid':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#txt_AreaName").val(data.d[0]);
                    $("#txt_Controlled").val(data.d[1]==null?"": data.d[1]);
                    $("#txt_Vs").val(data.d[2]==null?"":data.d[2]);
                    $("#btnEdit").show();
                    $("#btnAdd").hide();
                    divshow("main", "bg");
                }
            });
        }

        //添加数据
        function btn_Add() {
            var txt_AreaName = $("#txt_AreaName").val();
            var txt_Controlled = $("#txt_Controlled").val();
            var txt_Vs = $("#txt_Vs").val();
            $.ajax({
                type: "Post",
                url: "Company.aspx/Add",
                data: "{'AreaName':'" + txt_AreaName + "','Controlled':'" + txt_Controlled + "','Vs':'" + txt_Vs + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = 'Company.aspx';
                    }
                }
            });
        }

        //修改数据
        function btn_Edit() {
            var txt_AreaName = $("#txt_AreaName").val();
            var cid = $("#HidID").val();
            var txt_Controlled = $("#txt_Controlled").val();
            var txt_Vs = $("#txt_Vs").val();
            $.ajax({
                type: "Post",
                url: "Company.aspx/Edit",
                data: "{'cid':'" + cid + "','AreaName':'" + txt_AreaName + "','Controlled':'" + txt_Controlled + "','Vs':'" + txt_Vs + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = 'Company.aspx';
                    }
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="HidID" runat="server" />
    <div style="height:36px; line-height:36px; font-size:13px;">&nbsp;当前位置：分公司</div>
    <%if (Catering.Toolss.IsVerification(Session["RoleID"].ToString(), "System_Data.aspx", "分公司操作"))
                      { %>
    <div class="btn_list" style="margin-top:0px;">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
            
                <td align="right" height="30">
                    <input type="button" class="input_btn_a" value="添加" onclick="Add()" />
                </td>
            
                    <td>&nbsp;</td>
                <td width="10"></td>
            </tr>
        </table>
    </div><%} %>
    <div class="data_css">
        <table width="100%" border="1" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th width="20%">
                        公司名称
                    </th>
                    <th width="20%">
                        受控号
                    </th>
                    <th width="20%">
                        版本
                    </th>
                    <th width="20%">
                        编辑
                    </th>
                    <th width="20%">
                        删除
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater ID="Rep_OperationArea" runat="server" OnItemCommand="Rep_ItemCommand">
                    <ItemTemplate>
                        <tr>
                            <td>
                                <%#Eval("CName")%>
                            </td>
                            <td>
                                <%#Eval("Controlled")%>&nbsp;
                            </td>
                            <td>
                                <%#Eval("Vs")%>&nbsp;
                            </td>
                            <%if (Catering.Toolss.IsVerification(Session["RoleID"].ToString(), "System_Data.aspx", "分公司操作"))
                                  { %>
                            <td>
                                <img src="../../Images/file.gif" onclick="Edit('<%#Eval("id")%>')" style="cursor: pointer;" />
                            </td>
                            <td>
                                <asp:ImageButton ID="img_btn" runat="server" ImageUrl="../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                    CommandArgument='<%#Eval("id")%>' CommandName="del" />
                            </td>
                            <%}
                                  else
                                  { %>
                                  <td>&nbsp;</td><td>&nbsp;</td>
                                <%} %>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
    </div>
    <!--弹出层-->
    <div id="bg" class="bg">
    </div>
    <div id="main" class="center_div" style="width:260px; height:180px; padding: 0px;
        margin-top: -100px;">
        <div class="div_0207" style="width:258px; height:178px; margin:0px;">
            <h1><img src="../../Images/cp_h1_03.gif" />添加公司</h1>
            <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:6px;">
                <tr>
                    <td height="36" width="65" align="right">
                        名　称：
                    </td>
                    <td>
                        <asp:TextBox ID="txt_AreaName" runat="server" CssClass="input_bg"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right" height="36">受控号：</td>
                    <td><asp:TextBox ID="txt_Controlled" runat="server" CssClass="input_bg"></asp:TextBox></td>
                </tr>
                <tr>
                    <td align="right" height="36">版　本：</td>
                    <td><asp:TextBox ID="txt_Vs" runat="server" CssClass="input_bg"></asp:TextBox></td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td align="center">
                        <input type="button" id="btnAdd" onclick="btn_Add()" class="input_btn_a" value="提交" />
                        <input type="button" id="btnEdit" onclick="btn_Edit()" class="input_btn_a" value="提交" />
                    </td>
                    <td align="center">
                        <input type="button" id="but_Close" onclick='divhidel("main","bg")' class="input_btn_a" value="关闭" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>
</html>